import {ref,computed} from 'vue'
import dayjs from 'dayjs'

export const useCountDown = ()=>{

    const time = ref(0)

    //格式化数据
    const formatTime = computed(()=>dayjs.unix(time.value).format('mm分ss秒'))

    const start = (currentCountDown)=>{
        time.value = currentCountDown
        //定时减去时间
        setInterval(() => {
            time.value--
        }, 1000);
    }

    return{
        time,
        start,
        formatTime
    }
}